<!-- 日志分析的程序 -->
<template>
  <div>
    <el-table :data="logLists"  height="500" border style="width: 100%">
      <el-table-column prop="id" label="索引" width="50%"> </el-table-column>
      <el-table-column prop="ip" label="地址" width="70"> </el-table-column>
      <el-table-column prop="username" label="用户" width="70"> </el-table-column>
      <el-table-column prop="createDate" label="创建时间" width="160"> </el-table-column>
      <el-table-column prop="method" label="函数"> </el-table-column>
      <el-table-column prop="operation" label="操作"> </el-table-column>
      <el-table-column prop="params" label="参数"> </el-table-column>
    </el-table>
    <!-- 
        <el-table
        :data="tableData"
        style="width: 100%"
        :row-class-name="tableRowClassName"
        >
        <el-table-column prop="date" label="日期" width="180"> </el-table-column>
        <el-table-column prop="name" label="姓名" width="180"> </el-table-column>
        <el-table-column prop="address" label="地址"> </el-table-column>
        </el-table>
       -->
  </div>
</template>

<script>
export default {
  name: "LogInfo",
  data() {
    return {
      logLists: [],
      strDate:'',
      
    };
  },
  methods: {
    timestampToTime(timestamp) {
      let date = new Date(timestamp); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      let Y = date.getFullYear() + "-";

      let M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      let D =
        (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
      let h =
        (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
      let m =
        (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) +
        ":";
      let s =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();

      this.strDate = Y + M + D + h + m + s;
      return this.strDate;
    },

    async getLogList() {
      const { data: res } = await this.$http.post("/getAllLogInfo");
      //在这个地方是不需要这个下划线的
      for (let index = 0; index < res.length; index++) {
        res[index].createDate = this.timestampToTime(res[index].createDate);
      }
      console.log("====================================");
      console.log(res);
      console.log("====================================");
      this.logLists=res;
    },
  },
  created() {
    this.getLogList();
  },
};
</script>

<style  scoped>
</style>
